import request from '../../utils/request'
import {requestString} from '../../utils/request'

/**
 * 获取境外贸易商信息列表
 * @param cstId
 * @param page
 * @returns {Promise.<void>}
 */
export async function getBuyerList({cstId,status, page}) {
    return request(apiPath.mc + "/api/buyers", {
        method: 'get',
        data: {cstId, status, page: page.page, size: page.size}
    });
}


/**
 * 增加境外贸易商
 * @param params
 * @returns {Promise.<void>}
 */
export async function addBuyer({name, country, address, linkman, telephone, cstid, accounts}) {
    return requestString(apiPath.mc + "/api/buyer", {
        method: 'post',
        data: {name, country, address, linkman, telephone, cstid, accounts}
    });
}


/**
 * 更新境外贸易商
 * @param params
 * @returns {Promise.<void>}
 */
export async function updateBuyer({id, pname, country, address, linkman, telephone, cstid, accounts}) {
    return requestString(apiPath.mc + "/api/buyer", {
        method: 'put',
        data: {id, pname, country, address, linkman, telephone, cstid, accounts}
    });
}

/**
 * 根据id查境外贸易商
 * @param id
 * @returns {Promise.<void>}
 */
export async function getBuyerById({id}) {
    return request(apiPath.mc + "/api/buyer/"+ id, {
        method: 'get'
    });
}



/**
 * 删除境外贸易商
 * @param id
 * @returns {Promise.<void>}
 */
export async function deleteBuyerById({id}) {
    return request(apiPath.mc + "/api/buyer/"+ id, {
        method: 'delete'
    });
}